<?php
class SP_Helpers_GetPost
{

	private $strip_slashes=true;
	
	private function stripSlashes($str)
	{
		if(get_magic_quotes_gpc() && $this->strip_slashes)
		{	
			return SP_Common_Functions::stripSlashesDeep($str);
		}
		else
		{
			return $str;
		}
	}
	
	public function useStripSlashes($flag)
	{
		$this->strip_slashes=$flag;
	}
	
	public function get($name)
	{
		return $this->stripSlashes($_GET[$name]);
	}
	
	public function getBool($name)
	{
		if (isset($_GET[$name])) 
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	public function setGet($name,$value)
	{
		return $_GET[$name]=$value;
	}
	
	public function hasGet($name)
	{
		return isset($_GET[$name]);
	}
	
	public function post($name,$use_strip_slashes=NULL)
	{
		if(!$this->hasPost($name)) return null;
		if ($use_strip_slashes===NULL)
		{
			$use_strip_slashes=$this->strip_slashes;
		}
		return ($use_strip_slashes) ? $this->stripSlashes($_POST[$name]) : $_POST[$name];
	}
	
	public function postBool($name)
	{
		if (isset($_POST[$name])) 
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	public function setPost($name,$value)
	{
		return $_POST[$name]=$value;
	}
		
	public function hasPost($name)
	{
		if (is_array($_POST[$name])) return true;
		return (bool)strlen(trim($_POST[$name]));
	}
}
?>